WEBVTT

00:00.950 --> 00:06.980
Hello everybody and welcome to this solution off our Python standard library assessment quiz.

00:07.040 --> 00:13.850
So this Chris covers all topics of our basic section and if you master the Chris you can be sure that

00:13.850 --> 00:17.030
you will also have no problems with our case study.

00:17.030 --> 00:21.920
The second album challenge and actually then you can skip the whole basic section here.

00:23.180 --> 00:29.060
So the Chris has the 15 questions and of course the that easy questions and also harder more tricky

00:29.060 --> 00:30.340
questions.

00:30.470 --> 00:33.380
And if you do not have all 50 questions correct.

00:33.380 --> 00:40.040
So that's no problem as long as you can follow my solutions and think Okay I understand what the guy

00:40.040 --> 00:42.360
is trying to telling me here actually.

00:42.500 --> 00:42.680
Yeah.

00:42.680 --> 00:48.280
Then in this case you should be best prepared for the case study.

00:48.650 --> 00:50.110
So let's start our Chris

00:53.220 --> 00:54.810
a.m. The first question we have.

00:54.850 --> 00:58.190
Uh two two objects 3 and 7.

00:58.270 --> 01:04.130
And we assign the variable a two three and the variable B to seven.

01:04.420 --> 01:11.140
And if we add a and b Of course we get 10 so no surprise we can add integers and we use python as a

01:11.140 --> 01:11.970
calculator.

01:12.640 --> 01:14.200
So the correct answer is 10

01:19.600 --> 01:20.410
question 2.

01:20.440 --> 01:26.620
So the key message here is that you cannot add a string object with an integer like here in the first

01:26.620 --> 01:33.410
two answers so you can only add a string and string of its concatenated so the two strings and then

01:33.450 --> 01:35.550
we do not have this case here as an answer.

01:35.560 --> 01:42.460
And of course we can add two integers as we have here in this case so printing four plus six gives us

01:42.500 --> 01:45.860
10 so we do not get an error message here

01:50.420 --> 01:56.560
here we create a three copies of the string Hello World and are simply concatenated so the correct answer

01:56.560 --> 01:57.530
is here.

01:57.540 --> 01:58.140
This one

02:08.360 --> 02:10.580
here we have a list of the three elements.

02:10.580 --> 02:16.430
And if we multiply a list in that we have the key message here is and that follows.

02:16.450 --> 02:18.710
So that's no element y's operation.

02:18.860 --> 02:25.100
So actually we do not get multiplied elements like here and then this answer you ever you get um three

02:25.110 --> 02:29.060
maybe by Platt by three six multiplied by three and so on.

02:29.060 --> 02:31.010
But this is not how lists work.

02:31.070 --> 02:35.040
And actually we get to three times the copy off our list concatenate.

02:35.060 --> 02:42.930
So this is all a correct answer here.

02:42.990 --> 02:48.150
Here we have them the same list and all three options and then paste and we have the so-called zero

02:48.150 --> 02:53.970
based indexing saw fear fear a list we are starting at the index position zero.

02:53.980 --> 03:05.690
So the integer 2 has the index position zero and then we have one two three four five and six so consequently

03:05.750 --> 03:11.840
we are of a cat in our slice so kept us at index position 0 1 2.

03:11.880 --> 03:19.130
Was also want to have them three four including so we have the indexed positions two to four including

03:19.130 --> 03:19.410
the.

03:19.430 --> 03:23.940
We have to slice for two to five excluding.

03:23.990 --> 03:25.930
So this is the correct answer here

03:34.320 --> 03:39.100
so end this question to answer is actually a slice for the last two elements.

03:39.110 --> 03:46.700
So elephant and six point two and one does not so he and the first option we slice from minus two until

03:46.700 --> 03:48.530
the very last element.

03:48.540 --> 03:56.150
So alternatively to the zero base and next thing we can also index from minus one minus to minus three

03:56.150 --> 03:57.380
and so on.

03:57.560 --> 04:07.320
So minus two with Elif and until the very last element including So the first answer is correct then

04:07.320 --> 04:17.400
the second answer slices from the fifth element or the element at an exposition 5 0 1 2 3 4 5.

04:17.400 --> 04:20.570
It's elephant until the very last including.

04:20.850 --> 04:28.840
So this answer also slices at the very last elements and only here the last answer It slices only elephant.

04:28.950 --> 04:31.800
So in exposition 6 thus excluding

04:37.620 --> 04:43.190
this question here we have an example of in comparison operators so we have exclamation mark equal.

04:43.990 --> 04:47.690
And this checks if 10 is not equal to 9.

04:47.700 --> 04:50.090
And this is true.

04:50.340 --> 05:02.600
And if we apply not to uh gives us false so false is the correct answer here.

05:02.620 --> 05:06.340
Here we check whether dark in quotation mark is a string.

05:06.410 --> 05:09.180
And yes it's a string.

05:09.310 --> 05:13.660
And further we check whether 10 is greater than 8 and this is also true.

05:14.230 --> 05:21.600
And here we have one logical operator and and we only get a true here if all conditions are true.

05:21.610 --> 05:24.620
So dark is a string and time is greater than 8.

05:24.620 --> 05:32.340
And this is the case so we should get a true here.

05:32.370 --> 05:37.610
Here we have an if statement and at the end of this statement We need a colon.

05:37.650 --> 05:44.360
So here we have a colon and he also and after the statement we have to make and then to define the action

05:44.370 --> 05:45.240
we want to take.

05:45.240 --> 05:52.830
If the condition is correct and and does it automatically if you press enter after the if statement

05:53.430 --> 05:59.340
so he and this answer we do not have an intent here for for the print statement and therefore the only

05:59.490 --> 06:02.820
answer that we have a colon and an intent C at this one

06:10.520 --> 06:16.850
here we want to create a list of square numbers from 1 to 10 including and here we have the range object

06:17.350 --> 06:22.700
in the range object by default starts with 0 and the end value as exclusive.

06:22.820 --> 06:31.050
So this answer would give us some clear numbers from 0 to 9 including And the second key message of

06:31.050 --> 06:38.580
this question here is that also after a false statement or in the for loop we have to make a colon and

06:38.580 --> 06:51.190
an indent and here we do not have an intent so the only correct answer is this one here.

06:51.240 --> 06:58.230
Here we have a list of seven names and we want to create a list a names where all the names beginning

06:58.230 --> 07:03.750
with a name are included and only the names beginning with a.

07:03.820 --> 07:06.210
So the question is here we have three codes.

07:06.220 --> 07:12.670
And the question is how many of these codes do the job and the answer is actually that all three codes

07:12.700 --> 07:13.410
work.

07:13.480 --> 07:21.250
So here in the first code we iterate over the names and the first letter of the name is an A.

07:21.280 --> 07:24.180
We append the name to our names list.

07:24.370 --> 07:25.550
So this works.

07:25.690 --> 07:31.570
And the second code does actually the same chop in a list comprehension so we create here a list and

07:31.570 --> 07:37.090
for each name in the name lists we check if the first letter an A and if it is an A.

07:37.090 --> 07:39.820
We append the name into the list.

07:39.820 --> 07:46.050
So this works this letter and in code 3 it is a somewhat tricky one.

07:46.050 --> 07:51.580
So we first of all sort the names lists so the lists are starting with the names beginning with a.

07:52.500 --> 07:58.900
And then we are introducing a by loop and iterating over all indexed positions starting from an exposition

07:58.920 --> 08:00.300
zero of our list.

08:01.950 --> 08:09.990
And as long as the first letter isn't a We append the name to our lists and we increase the index position

08:10.050 --> 08:13.080
by 1 and check the next name.

08:13.080 --> 08:21.180
So this was actually a quite tricky question and the correct answers is three.

08:21.380 --> 08:21.770
All right.

08:21.780 --> 08:29.520
So here we have a list with integers from 1 to 20 and we want to create a new list that contains all

08:29.520 --> 08:36.390
elements of the list that are divisible by three of us out remainder and all other elements would be

08:36.390 --> 08:37.890
stored in another list.

08:37.930 --> 08:41.300
And and that's another condition here.

08:41.310 --> 08:44.400
So the element 3 must not be in any of the new lists.

08:44.400 --> 08:51.600
So actually 3 is actually divisible by three without remainder but it should not be in our list at all.

08:52.770 --> 08:55.090
Let's have a look at the options here.

08:57.310 --> 09:01.750
So actually the answers are from here on are identical.

09:02.530 --> 09:07.530
So if our element is divisible by three we attended to the list.

09:07.540 --> 09:14.950
Uh and as we appended to the list M however the key message is that first of all we have to check whether

09:14.950 --> 09:19.310
we have the element three in our list so.

09:19.380 --> 09:22.290
If this is the case we have to ignore three.

09:22.320 --> 09:24.970
This the keyboard argument continue.

09:24.990 --> 09:27.530
So here if you come to three in our list.

09:27.630 --> 09:32.730
We just ignore three and go on lists then the next element four.

09:33.090 --> 09:34.800
So this is correct.

09:34.800 --> 09:37.250
And here we do not check if we have three.

09:37.250 --> 09:41.160
So actually I would expect to have and three in our list.

09:41.180 --> 09:45.810
L And here we are checking if we have three in our list.

09:45.810 --> 09:47.900
But if we have three we break.

09:47.910 --> 09:50.070
So we completely break the for loop.

09:50.070 --> 09:54.300
So after the first three elements our iteration stops here.

09:54.780 --> 09:57.860
So the correct answer is um the first one

10:04.970 --> 10:11.780
here we define the function division and we have two arguments of the function A and B and B has an

10:11.810 --> 10:17.210
defined parameter equals 1 and the function returns a divided by B.

10:17.240 --> 10:25.640
So if we call the function by just passing 5 so 5 stands for our argument a and for B we have the default

10:25.640 --> 10:26.590
parameter 1.

10:26.600 --> 10:33.670
If you do not set a concrete parameter by calling our function so we saw tests 5 divided by 1.

10:33.710 --> 10:36.020
So this should be the correct answer.

10:39.570 --> 10:45.590
So here we want to create a function that returns to the sum of randomly generated integers and they

10:45.580 --> 10:53.580
interpret the 1 to 10 and we want to be able to set the size of the randomly generated integers as a

10:53.670 --> 10:56.410
monumental parameter off the function.

10:56.520 --> 10:59.270
So we have here two key messages.

10:59.270 --> 11:06.180
So first of all you want to create random integers in range 1 to 10 and answer 2 and 3 do exactly this

11:06.630 --> 11:11.040
but answer 1 creates the random float in range 0 to 1.

11:11.040 --> 11:18.210
So this is not correct and then Option 2 and 3 we can pass a parameter size.

11:18.210 --> 11:23.360
However if we have a look at the function body so he can answer 3.

11:23.360 --> 11:26.070
We have the concrete size 100.

11:26.150 --> 11:33.640
So even if we change the size and then the function header we always get a size of hundred random integers.

11:33.650 --> 11:36.340
And therefore here.

11:36.650 --> 11:38.300
So number 2 is correct.

11:38.300 --> 11:42.830
So here we are able to define the number of random integers we want to create

11:50.450 --> 11:50.800
all right.

11:50.810 --> 11:58.190
So last question here we have a say it's men and with say it's low we have 700 in 2010 900 say it's

11:58.190 --> 12:05.210
in two thousand eleven and so on and we want to create a line plot to visualize ourselves and we want

12:05.210 --> 12:16.400
to have the Yes on the x axis and the states on the y axis and we have to implement plot live here and

12:16.400 --> 12:22.440
the first answer I guess that's actually a scatter blood another line plot so this is not correct and

12:22.440 --> 12:29.920
here the function party plot we have we have to define as the first argument on the x axis so we have

12:29.950 --> 12:37.650
yes and as the second argument say is so answer 3 is actually the way around and therefore we have to

12:37.650 --> 12:39.120
choose answer to.
